home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
Æ Stream Library 1.0
/
AEStream_CPlus.h
< prev
next >
Wrap
Text File
|
1991-09-27
|
4KB
|
109 lines
////
//// AEStream_CPlus.h A (write-only) stream for creating AE Descriptors.
//// This header file for use with C++. Use AEStream.h with C.
////
//// By Jens Alfke ©1991 Apple Computer, Inc. All rights reserved.
////
// NOTE: This header file is for C++ programs only. If you #include "AEStream.h" in a C++
// program, you'll get this header anyway.
// NOTE: In case of disagreement between this header and the C one (AEStream.h),
// this header is correct and the C header needs to be fixed.
#ifndef __AESTREAM__
#define __AESTREAM__
#ifndef __MEMORY__
#include <Memory.h>
#endif
#ifndef __APPLEEVENTS__
#include <AppleEvents.h>
#endif
const errAEStream_BadNesting = 13579; // Bad descriptor/array nesting error
// Here are the C-style definitions, which are the actual functions implemented:
struct AEStream;
struct AEStreamMark;
extern "C" {
OSErr
AEStream_Open ( AEStream& ),
AEStream_Close ( AEStream&, AEDesc *desc ),
AEStream_WriteDesc ( AEStream&, DescType type, const void *data, Size length ),
AEStream_WriteAEDesc( AEStream&, const AEDesc &desc ),
AEStream_OpenDesc ( AEStream&, DescType type, AEStreamMark &mark ),
AEStream_WriteData ( AEStream&, const void *data, Size length ),
AEStream_CloseDesc ( AEStream&, const AEStreamMark &mark ),
AEStream_OpenList ( AEStream&, AEStreamMark &mark ),
AEStream_CloseList ( AEStream&, const AEStreamMark &mark ),
AEStream_OpenRecord ( AEStream&, DescType type, AEStreamMark &mark ),
AEStream_CloseRecord( AEStream&, const AEStreamMark &mark ),
AEStream_WriteKeyDesc(AEStream&, DescType key,
DescType type, const void *data, Size length ),
AEStream_OpenKeyDesc( AEStream&, DescType key, DescType type, AEStreamMark &mark ),
AEStream_WriteKey ( AEStream&, DescType key );
}
// Here are the data structures, complete with fancy C++ inline methods to call the above fns:
struct AEStreamMark { // Mark descriptor
Size sizeIndex;
Size countIndex;
};
struct AEStream { // A (write-only) stream on an AE descriptor
Handle data; // The data
Size index; // Current index (into data handle) to write to
AEStreamMark mark; // Current mark: Index to size/length field of open desc/array/record
Size size; // Current size of handle
AEStream();
~AEStream();
inline OSErr
Close ( AEDesc *desc )
{return AEStream_Close(*this,desc);}
OpenDesc ( DescType type, AEStreamMark &mark )
{return AEStream_OpenDesc(*this,type,mark);}
WriteData ( const void *data, Size length )
{return AEStream_WriteData(*this,data,length);}
CloseDesc ( const AEStreamMark &mark )
{return AEStream_CloseDesc(*this,mark);}
WriteDesc ( DescType type, const void *data, Size length )
{return AEStream_WriteDesc(*this,type,data,length);}
WriteDesc ( const AEDesc &desc )
{return AEStream_WriteAEDesc(*this,desc);}
OpenList ( AEStreamMark &mark )
{return AEStream_OpenList(*this,mark);}
CloseList ( const AEStreamMark &mark )
{return AEStream_CloseList(*this,mark);}
OpenRecord ( DescType type, AEStreamMark &mark )
{return AEStream_OpenRecord(*this,type,mark);}
CloseRecord ( const AEStreamMark &mark )
{return AEStream_CloseRecord(*this,mark);}
WriteKeyDesc( DescType key, DescType type, void *data, Size length )
{return AEStream_WriteKeyDesc(*this,key,type,data,length);}
OpenKeyDesc ( DescType key, DescType type, AEStreamMark &mark )
{return AEStream_OpenKeyDesc(*this,key,type,mark);}
WriteKey ( DescType key )
{return AEStream_WriteKey(*this,key);}
};
#endif